<template>
  <div class="bg-box">
    <div class="header">
      <Cheader content="企业风险分区综合查询"></Cheader>
    </div>
    <div class="middle-box">
      <div class="container">
        <div
          class="items"
          v-for="item in data"
          :key="item.label"
          :class="[cur == item.label ? 'active' : '']"
          @click="toAnther(item.label)"
        >
          {{ item.name }}
        </div>
      </div>
    </div>
    <el-row class="table-area">
      <el-row type="flex"  :gutter="20" justify="space-around" class="r-area el-row1">
        <el-col :span="5">
          <div
            style="
              background-color: #fde2da;
              border-radius: 6px;
              display: flex;
              justify-content: space-around;
              min-width: 202px;
            "
          >
            <div class="l-div">
              <span>红区总数：</span
              ><span style="font-size: 18px; font-weight: 600">{{red}}</span>
            </div>
            <div class="r-div">
              <span>占比数：</span
              ><span style="font-size: 18px; font-weight: 600">{{redpercent}}</span>
            </div>
          </div>
        </el-col>
        <el-col :span="5">
          <div
            style="
              background-color: #fdecda;
              border-radius: 6px;
              display: flex;
              justify-content: space-around;
              min-width: 202px;
            "
          >
            <div class="l-div">
              <span>橙区总数：</span
              ><span style="font-size: 18px; font-weight: 600">{{orange}}</span>
            </div>
            <div class="r-div">
              <span>占比数：</span
              ><span style="font-size: 18px; font-weight: 600">{{orangepercent}}</span>
            </div>
          </div>
        </el-col>
        <el-col :span="5">
          <div
            style="
              background-color: #fdf6da;
              border-radius: 6px;
              display: flex;
              justify-content: space-around;
              min-width: 202px;
            "
          >
            <div class="l-div">
              <span>黄区总数：</span
              ><span style="font-size: 18px; font-weight: 600">{{yellow}}</span>
            </div>
            <div class="r-div">
              <span>占比数：</span
              ><span style="font-size: 18px; font-weight: 600">{{yellowpercent}}</span>
            </div>
          </div>
        </el-col>
        <el-col :span="5">
          <div
            style="
              background-color: #dae9fd;
              border-radius: 6px;
              display: flex;
              justify-content: space-around;
              min-width: 202px;
            "
          >
            <div class="l-div">
              <span>蓝区总数：</span
              ><span style="font-size: 18px; font-weight: 600">{{blue}}</span>
            </div>
            <div class="r-div">
              <span>占比数：</span
              ><span style="font-size: 18px; font-weight: 600">{{bluepercent}}</span>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <div class="table-box">
          <el-row type="flex" style="padding: 0 16px">
            <el-col :span="6" class="e-s-10">
              <span>合计：</span>
              <span>{{countsum}}</span>
            </el-col>
            <el-col :span="15" class="e-c-15">
              <input
                type="text"
                class="input-search"
                placeholder="输入企业名称查询"
              />
              <div class="img-bg">
                <img src="../../../assets/images/main/icon-search.png" />
              </div>
            </el-col>
            <el-col :span="3" class="e-c-4">
              <div class="bt-dc">导出</div>
            </el-col>
          </el-row>
          <el-row class="table-row">
            <el-table
              :cell-style="tableRowStyle"
              :data="tableData"
              v-loading="loading"
              height="315px"
              border
              style="width: 100%"
            >
              <el-table-column
                align="center"
                prop="serial"
                min-width="40%"
                label="序号"
              >
              </el-table-column>
              <el-table-column min-width="100%" prop="name" label="企业名称">
              </el-table-column>
              <el-table-column
                min-width="80%"
                prop="address"
                label="所属县区"
              ></el-table-column>
              <el-table-column
                align="center"
                min-width="50%"
                prop="redArea"
                label="红区"
                class="font-blue"
              ></el-table-column>
              <el-table-column
                align="center"
                min-width="50%"
                prop="orangeArea"
                label="橙区"
                class="font-blue"
              ></el-table-column>
              <el-table-column
                min-width="50%"
                align="center"
                prop="yellowArea"
                label="黄区"
                class="font-blue"
              ></el-table-column>
              <el-table-column
                align="center"
                min-width="50%"
                prop="blueArea"
                label="蓝区"
                class="font-blue"
              ></el-table-column>
              <el-table-column
                min-width="50%"
                align="center"
                prop="fourColorImage"
                label="四色图"
                class="font-blue"
              ></el-table-column>
            </el-table>
          </el-row>
        </div>
      </el-row>
    </el-row>
    <el-row class="table-area">
      <el-row type="flex" :gutter="40" justify="start" class="e-row1 el-row1">
        <el-col :span="2">
          <div class="div-red">
            <span>红区：</span>
            <span>{{red_number}}</span>
          </div>
        </el-col>
        <el-col :span="2">
          <div class="div-orange">
            <span>橙区：</span>
            <span>{{orange_number}}</span>
          </div>
        </el-col>
        <el-col :span="2">
          <div class="div-yellow">
            <span>黄区：</span>
            <span>{{yellow_number}}</span>
          </div>
        </el-col>
        <el-col :span="2">
          <div class="div-blue">
            <span>蓝区：</span>
            <span>{{blue_number}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="table-row">
        <el-table
          :data="bottomTableData"
          v-loading="loading"
          height="315px"
          border
          style="width: 100%"
        >
          <el-table-column
            align="center"
            prop="serial"
            min-width="40%"
            label="序号"
          >
          </el-table-column>
          <el-table-column min-width="100%" prop="address" label="区域名称">
          </el-table-column>
          <el-table-column
            min-width="80%"
            prop="riskGrade"
            label="风险等级"
          ></el-table-column>
          <el-table-column
            align="center"
            min-width="50%"
            prop="inherentRiskGrade"
            label="固有风险等级"
            class="font-blue"
          ></el-table-column>
          <el-table-column
            align="center"
            min-width="50%"
            prop="controlRiskGrade"
            label="控制风险等级"
            class="font-blue"
          ></el-table-column>
        </el-table>
      </el-row>
    </el-row>
  </div>
</template>

<script>
import Cheader from "@/components/Cheader/Cheader.vue";
import { requestPost ,requestGet} from '@/network/request';
export default {
  name: "qyfxfqzhcx",
  data() {
    return {
      cur: "",
      data: [],
      tableData: [],
      bottomTableData: [],
      loading: false,
    };
  },
  created() {
    this.getAreaName();
    this.getData();
    this.companyfxfqSingle();
  },
  components: {
    Cheader,
  },
  methods: {
    // 获取表格数据的方法
    getData() {
      this.tableData=[];
      this.bottomTableData=[];
      this.loading = true
      setTimeout(()=>{
        requestPost("/wwyt/qyfxfqzhcx/companyfxfqTj",{"area_code":this.cur}).then(res=>{
          if(res.code == 200  && res.data.length > 0){
            this.tableData=res.data;
            this.countsum=res.data.length;
          }
        })
        requestPost("/wwyt/qyfxfqzhcx/companyfxfqHz",{}).then(res=>{
          if(res.code == 200  && res.data.length > 0){
            this.bottomTableData=res.data;
          }
        })
        requestPost("/wwyt/qyfxfqzhcx/fxfqsSumTj",{"area_code":this.cur}).then(res=>{
          if(res.code == 200  && res.data.length > 0){
            this.red=res.data[0].red;
            this.orange=res.data[0].orange;
            this.yellow=res.data[0].yellow;
            this.blue=res.data[0].blue;
            if(res.data[0].red==0&&res.data[0].orange==0&&res.data[0].yellow==0&&res.data[0].blue==0){
              this.redpercent="0%";
            }else{
              this.redpercent=`${((res.data[0].red/(res.data[0].red+res.data[0].orange+res.data[0].yellow+res.data[0].blue))*100).toFixed(2)}%`;
            }
            if(res.data[0].red==0&&res.data[0].orange==0&&res.data[0].yellow==0&&res.data[0].blue==0){
              this.orangepercent="0%";
            }else{
              this.orangepercent=`${((res.data[0].orange/(res.data[0].red+res.data[0].orange+res.data[0].yellow+res.data[0].blue))*100).toFixed(2)}%`;
            }
            if(res.data[0].red==0&&res.data[0].orange==0&&res.data[0].yellow==0&&res.data[0].blue==0){
              this.yellowpercent="0%";
            }else{
              this.yellowpercent=`${((res.data[0].yellow/(res.data[0].red+res.data[0].orange+res.data[0].yellow+res.data[0].blue))*100).toFixed(2)}%`;
            }
            if(res.data[0].red==0&&res.data[0].orange==0&&res.data[0].yellow==0&&res.data[0].blue==0){
              this.bluepercent="0%";
            }else{
              this.bluepercent=`${((res.data[0].blue/(res.data[0].red+res.data[0].orange+res.data[0].yellow+res.data[0].blue))*100).toFixed(2)}%`;
            }
          }
        })
      this.loading = false
      },500)
    },
    toAnther(id) {
      this.cur = id;
      this.getData();
    },
    tableRowStyle({ columnIndex }) {
      if (columnIndex === 7 || columnIndex === 1) {
        return "color:#4D7EE9;!important;text-decoration: underline;cursor:pointer";
      }
    },
    companyfxfqSingle(){
      requestPost("/wwyt/qyfxfqzhcx/companyfxfqSingle",{}).then(res=>{
          if(res.code == 200  && res.data.length > 0){
            this.red_number=res.data[0].red;
            this.orange_number=res.data[0].orange;
            this.yellow_number=res.data[0].yellow;
            this.blue_number=res.data[0].blue;
          }
        })
    },
    getAreaName(){
      requestGet("/manageArea/selectAreaName").then(res=>{
        if(res.code==200&&res.data.length>0){
          this.data=res.data;
        }
      })
    },
  },
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
.el-row1 {
  margin: 0 !important;
}
.container {
  display: flex;
  padding-top: 20px;
  margin-left: 27px;
  .items {
    min-width: 65px;
  }
  .items:first-child {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 10px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #5d6c8e;
    background: #ffffff;
    border: 1px solid #e3e6ec;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
  }
  .items:last-child {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 10px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #5d6c8e;
    background: #ffffff;
    border: 1px solid #e3e6ec;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
  }
  .items:not(:first-child):not(:last-child) {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 10px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #5d6c8e;
    background: #ffffff;
    border: 1px solid #e3e6ec;
    cursor: pointer;
  }
  .active {
    background: #5184ea !important;
    color: #fefefe !important;
    &::before {
      content: "";
      position: absolute;
      top: 30px;
      left: 50%;
      border-top: 5px solid #5184ea;
      border-left: 5px solid transparent;
      border-bottom: 5px solid transparent;
      border-right: 5px solid transparent;
    }
  }
}
.bg-box {
  overflow: auto;
}
.header {
  text-align: left;
  background-color: #ffffff;
}
.middle-box {
  font-family: Microsoft YaHei;
  padding-bottom: 10;
}
.r-area {
  font-size: 15px;
  font-family: Arial;
  font-weight: 400;
  color: #364064;
  height: 60px;
}
.table-box {
  .img-bg {
    width: 39px;
    height: 32px;
    text-align: center;
    background: #5184ea;
    border-radius: 0 4px 4px 0;
  }
  .e-s-10 {
    text-align: left;
    margin-left: 15px;

    :last-child {
      font-weight: 800;
    }
  }
  .e-c-15 {
    display: flex;
    justify-content: right;
    .input-search {
      border: 1px solid #e3e6ec;
      height: 30px;
    }
  }
  .bt-dc {
    width: 82px;
    height: 32px;
    background: linear-gradient(90deg, #5177e4 0%, #5186eb 100%);
    box-shadow: 0 2px 4px 0 rgba(81, 133, 235, .5);
    border-radius: 4px;
    font-size: 16px;
    text-align: center;
    font-weight: 400;
    color: #ffffff;
    line-height: 32px;
    float: right;
    margin-right: 15px;
    cursor: pointer;
  }
  input::input-placeholder {
    color: #c3cada;
  }
  ::-webkit-input-placeholder {
    /* WebKit browsers */
    color: #c3cada;
    font-size: 14px;
    padding: 1px 10px;
  }
  :-moz-placeholder {
    /* Mozilla Firefox 4 to 18 */
    color: #c3cada;
    font-size: 14px;
    padding: 1px 10px;
  }
  ::-moz-placeholder {
    /* Mozilla Firefox 19  */
    color: #c3cada;
    font-size: 14px;
    padding: 1px 10px;
  }
  :-ms-input-placeholder {
    /* Internet Explorer 10  */
    color: #c3cada;
    font-size: 14px;
    padding: 0 10px;
  }
}
.table-row {
  margin: 8px 30px;
}
.el-table {
  :deep ::-webkit-scrollbar {
    width: 6px; /*滚动条宽度*/
  }
  :deep ::-webkit-scrollbar-track {
    border-radius: 0; /*滚动条的背景区域的圆角*/
  }
  :deep ::-webkit-scrollbar-corner {
    background-color: rgba(2, 29, 87, 1);
  }
  :deep ::-webkit-scrollbar-thumb {
    border-radius: 4px; /*滚动条的圆角*/
    background: rgba(81, 132, 234, .5); /*滚动条的背景颜色*/
  }
  :deep ::-ms-scrollbar {
    width: 6px; /*滚动条宽度*/
  }
  :deep ::-ms-scrollbar-track {
    border-radius: 0; /*滚动条的背景区域的圆角*/
  }
  :deep ::-ms-scrollbar-corner {
    background-color: rgba(2, 29, 87, 1);
  }
  :deep ::-ms-scrollbar-thumb {
    border-radius: 4px; /*滚动条的圆角*/
    background: rgba(81, 132, 234, .5); /*滚动条的背景颜色*/
  }
  :deep ::-moz-scrollbar {
    width: 6px; /*滚动条宽度*/
  }
  :deep ::-moz-scrollbar-track {
    border-radius: 0; /*滚动条的背景区域的圆角*/
  }
  :deep ::-moz-scrollbar-corner {
    background-color: rgba(2, 29, 87, 1);
  }
  :deep ::-moz-scrollbar-thumb {
    border-radius: 4px; /*滚动条的圆角*/
    background: rgba(81, 132, 234, .5); /*滚动条的背景颜色*/
  }
}
:deep .el-table th {
  box-sizing: border-box;
  color: #5d6c8e;
  background-color: #f0f4f9;
  padding: 0;
}
:deep .el-table td {
  padding: 7px 5px;
}
.col-month {
  width: 96px;
  height: 32px;
  float: right;
  text-align: center;
  line-height: 32px;
  margin-top: 12px;
  color: #364064;
  font-size: 16px;
  background-color: #ffffff;
}
.table-area {
  margin-top: 15px;
  padding: 20px 0 0 0;
  background-color: #ffffff;
  border: 1px solid #dadfea;
  box-shadow: 0 0 19px 1px rgba(116, 118, 138, 0.16);
  .e-row1 {
    padding: 0 0 5px 8px;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #ffffff;
  }
  .div-red {
    min-width: 58px;
    text-align: center;
    background: linear-gradient(90deg, #ff6e79 0%, #ffb7b8 100%);
    border-radius: 18px;
  }
  .div-orange {
    min-width: 58px;
    text-align: center;
    background: linear-gradient(90deg, #ff8a69 0%, #ffc5a8 100%);
    border-radius: 18px;
  }
  .div-yellow {
    min-width: 58px;
    text-align: center;
    background: linear-gradient(90deg, #ffd456 0%, #ffec96 100%);
    border-radius: 18px;
  }
  .div-blue {
    min-width: 58px;
    text-align: center;
    background: linear-gradient(90deg, #5784ff 0%, #94abfb 100%);
    border-radius: 18px;
  }
}
</style>
